<?php
namespace app\common\model;

use think\Db;
use think\Model;

/**   YSF
 *    投诉模型  Model
 *    Date: 2018/9/3
 * Class ComplaintModel
 * @package app\common\model
 */
class ComplaintModel extends Model
{
    // 表名
    protected $dbName = 'complaint';

    // 列表查询
    public function getAll($where, $join, $nowPage, $limits, $field, $order)
    {
        $result = Db::name($this->dbName)->alias('a')
                    ->where($where)
                    ->join($join)
                    ->page($nowPage, $limits)
                    ->field($field)
                    ->order($order)
                    ->select();
        return $result;
    }

    // 数量统计
    public function getCount($where, $join)
    {
        $result = Db::name($this->dbName)->alias('a')->where($where)->join($join)->count();
        return $result;
    }

    // 单条查询
    public function getOne($where, $field = '*')
    {
        $result = Db::name($this->dbName)->where($where)->field($field)->find();
        return $result;
    }

    // 连表单条查询
    public function getJoinOne($where, $join, $field='*')
    {
        $result = Db::name($this->dbName)
                        ->alias('a')
                        ->where($where)
                        ->join($join)
                        ->field($field)
                        ->find();
        return $result;
    }

    // 修改操作
    public function edit($where, $data)
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->update($data);
        return $result;
    }

}